package net.flyinggroup.mutation;

import net.flyinggroup.mutation.model.Book;
import net.flyinggroup.mutation.model.Review;
import net.flyinggroup.mutation.repository.BookRepository;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.util.List;

@SpringBootApplication
public class MutationApplication {

    public static void main(String[] args) {
        SpringApplication.run(MutationApplication.class, args);
    }

    @Bean
    public CommandLineRunner commandLineRunner(BookRepository repository) {
        return args -> {
            Review review = new Review("Great Book", "I really enjoyed this book");
            Book reactiveString = new Book("Reactive Spring", 484, "Josh Long", List.of(review));
            repository.save(reactiveString);
        };
    }
}
